package com.wisemoresystem.seal.action.seal.news;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.model.t_seal_new;
import com.wisemoresystem.seal.model.t_seal_new_factory_log;
import com.wisemoresystem.seal.model.t_seal_type;
import com.wisemoresystem.seal.model.t_seal_type_config;
import com.wisemoresystem.seal.service.SealNewService;

/**
 * 印章 出厂 登记 复核
 * 
 * @author Administrator
 *
 */
@Controller("sealNewsBackVerify")
@Scope("prototype")
@RequestMapping("/ix/seal/news/engraving_verify")
public class SealNewsEngravingBackVerifyAction extends ProjBaseAction {
	@Autowired
	private SealNewService sealnewService;

	/**
	 * 印章出场登记复核列表
	 * 
	 * @return
	 */
	@RequestMapping("/list")
	public ModelAndView list() {

		List<Map<String, Object>> list = sealnewService
				.selectSealNewEngravingVerifyingList(page);

		ModelAndView mv = new ModelAndView(
				"/jsp/seal/news/engraving_verify/list");
		mv.addObject("list", list);
		return mv;
	}

	/**
	 * 印章登记复核的详细信息
	 * 
	 * @param sealnew_id
	 *            新章申请id
	 * @return
	 */
	@RequestMapping("/verify_form")
	public ModelAndView verify_form(String sealnew_id) {

		t_seal_new sealNew = (t_seal_new) oc.findObjById(sealnew_id,
				t_seal_new.class);
		t_seal_type sealType = (t_seal_type) oc.findObjById(
				sealNew.getSeal_type_id(), t_seal_type.class);
		t_seal_type_config sealTypeConfig = (t_seal_type_config) oc
				.findObjById(sealNew.getSeal_type_config_id(),
						t_seal_type_config.class);

		t_seal_new_factory_log factoryLog = sealnewService
				.getVerifyLog(sealnew_id);

		ModelAndView mv = new ModelAndView(
				"/jsp/seal/news/engraving_verify/verify_form");
		mv.addObject("sealNew", sealNew);
		mv.addObject("sealType", sealType);
		mv.addObject("sealTypeConfig", sealTypeConfig);
		mv.addObject("factoryLog", factoryLog);
		return mv;
	}

	/**
	 * 印章登记复核
	 * 
	 * @param sealnew_id
	 *            新章id
	 * @param flag
	 *            状态
	 * @return
	 */
	@RequestMapping("/verify")
	public ModelAndView verify(String sealnew_id, String flag) {
		sealnewService.backVerify(sealnew_id, flag);

		logT.logH("印章登记复核", t_seal_new.class, sealnew_id);

		this.setTipMsg("复核完成.");
		ModelAndView mv = new ModelAndView("redirect:list.htm");
		return mv;
	}
}
